#ifndef __WORK_CMD__
#define __WORK_CMD__
#include "my_header.h"
#define TIME_SLICE 300
#define SATL_LEN 14
#define MD5_SIZE 16
#define MD5_STR_LEN (MD5_SIZE * 2)

typedef enum{
    REGISTER = 0,
    LOGIN,
    LS,
    CD,
    PWD,
    PUTS,
    GETS,
    REMOVE,
    MKDIR,
    RMDIR,
    TOKEN,
}commandType;

typedef struct train_s{
    int length;
    char data[4096];
}train_t;

typedef struct trainState_s{
    int length;
    int state;
    //注册登录，记录用户名长度
    //命令，记录部分命令长度
    int preLength;
    char buf[1024];
}trainState_t;

//用户注册登录
int registerUser(int sockFd);
int login(int sockFd,char *userName);
int token(int sockFd,char *token);
int encode(char *key, char *userName,char *token);

//处理命令
int recvn(int sockfd, void *buf, int length);
int printStat(struct stat statbuf,char *name);
int upload(int netFd,char *file);
int download(int netFd);

int handleCmd(trainState_t trainState, int netFd);

#endif
